Skip to content

Create Smart Battery Module #3944

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 38 commits into from
Aug 17, 2025
Merged

Conversation

RKBoss6
Copy link
Contributor

@RKBoss6 RKBoss6 commented Jul 23, 2025

This provides a module an app can use for battery. It learns your usage patterns over time by averaging out drainage rates, and extrapolates that into a pretty accurate prediction.

@RKBoss6 RKBoss6 marked this pull request as draft July 23, 2025 20:12
@RKBoss6
Copy link
Contributor Author

RKBoss6 commented Jul 23, 2025

Right now there's a bunch of code for logging, might remove that later on or make it a toggle in settings

@RKBoss6 RKBoss6 marked this pull request as ready for review July 24, 2025 19:52
@RKBoss6
Copy link
Contributor Author

RKBoss6 commented Jul 24, 2025

I made logging an option in settings, app is good to go. This is my first module I've made, so if anything looks strange, I would love to get feedback on it :)

@RKBoss6 RKBoss6 marked this pull request as draft July 29, 2025 02:06
@RKBoss6 RKBoss6 marked this pull request as ready for review July 30, 2025 18:13
@RelapsingCertainly
Copy link

I decided to try it out on physical hardware.

Currently the behaviour is weird where it shows 0hr (logging off) but turning on loging gives me a figure ranging from 8hr to 99days (which i expected).

Hopefully it is just a temp thing and in a day or so it starts working properly. We shall see

P.S. Isnt logging just for debuging? Or does it actually have an effect on the module?

@RKBoss6
Copy link
Contributor Author

RKBoss6 commented Jul 30, 2025

@RelapsingCertainly Logging shouldn't change anything fundamental, you're right, it's just for debugging. Give it up to 2 days to see if the drainage rate is just fluctuating, and it's still learning from that. I would love to hear a status update on this later on :)

PS: how did you install the app? If you copied the files into the ide and uploaded it, maybe something went awry there...

@RKBoss6
Copy link
Contributor Author

RKBoss6 commented Aug 2, 2025

@RelapsingCertainly I added the clockInfo, and added a second one for average battery drainage. Try reinstalling the app from my app loader, and check it out!

@RelapsingCertainly
Copy link

RelapsingCertainly commented Aug 3, 2025

The clock info is broken again, idk if it my watch or just the clock info but it's not updating either on charge or to show the new estimate.

P.s. Power manager might be broken since the battery percentage stays the same charging or not until its reloaded. Im currently running an experiment to see if 0.12 is indeed broken, ill report back with my finding.

P.p.s turns out this module is a hard thing to test since my previous typical drainage would be around 5% per day.

@RelapsingCertainly
Copy link

Well im back and can confirm, powermanager stable percentage is broken. After disabling it, both clock infos are working as they should.

@RKBoss6
Copy link
Contributor Author

RKBoss6 commented Aug 4, 2025

@RelapsingCertainly How is it broken? I have it installed for me, and it works well...

@RKBoss6
Copy link
Contributor Author

RKBoss6 commented Aug 4, 2025

Ok, I see what's broken now, created #3958 to fix that. Thanks!

@RelapsingCertainly
Copy link

Have been using it for a bit, it looks like the time remaining only goes down.

So if i had 10 days of battery left and charge it, even if i now have 14 days, it will stay on 10 days remaining for 4 days until it loses another day.

@RKBoss6
Copy link
Contributor Author

RKBoss6 commented Aug 12, 2025

@RelapsingCertainly That's really strange... Mine works perfectly. That being said, my battery life on a full charge is a woeful 5 days, so it might be something with your long battery life. If you want to, try clearing the data from the module via settings, and turn HRM or GPS on to see if that is still a problem, in which case it might be a faulty installation. Try reinstalling it from my app loader (again :) if so )...

@RKBoss6
Copy link
Contributor Author

RKBoss6 commented Aug 12, 2025

Btw, thanks for all the testing! I would have never caught these issues on my own :)

@RelapsingCertainly
Copy link

Oh damn, recorder is a very good battery tool lol, it instantly lowered my estimation to 3 hrs so once its drained a little, im gonna put it on charge again and then see if it increases over 3hrs.

If that fails, ill reinstall and such.

Btw when do u recharge ur watch? Like do u let it die or like what is ur minimum time left before charging?

@RelapsingCertainly
Copy link

Btw, thanks for all the testing! I would have never caught these issues on my own :)

Well... have to find a way to delay making my own bangle apps somehow :P

Copy link
Collaborator

@bobrippling bobrippling left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, two smaller suggestions :)

@RelapsingCertainly
Copy link

RelapsingCertainly commented Aug 16, 2025

This pr is ready to merge, turns out the weird behaviour was just to how slowly my bangle drain (and how during testing drains faster) which lead to the drainage value being out of wack (i.e. showing a higher drain than actual, not by alot but by enough where its confusing)

For most people it should work perfectly given they are not actively testing the battery and such

@RKBoss6
Copy link
Contributor Author

RKBoss6 commented Aug 16, 2025

Btw when do u recharge ur watch? Like do u let it die or like what is ur minimum time left before charging?

I generally charge it around 5-10%, and try charging it no more than 80% to protect the battery life. I think around 5h left is when I charge it

@bobrippling
Copy link
Collaborator

I generally charge it around 5-10%, and try charging it no more than 80% to protect the battery life. I think around 5h left is when I charge it

Same for me. And thanks for checking the PR @RelapsingCertainly!

@bobrippling bobrippling merged commit 1ff8162 into espruino:master Aug 17, 2025
1 check passed
@bobrippling
Copy link
Collaborator

Thanks again for the PR!

@RKBoss6 RKBoss6 deleted the smartbatt-module branch August 18, 2025 00:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants